package com.fdq.dianping.controller;


import com.fdq.dianping.entity.BlogComments;
import com.fdq.dianping.entity.Result;
import com.fdq.dianping.service.IBlogCommentsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fdq
 * @since 2025-01-25
 */
@RestController
@RequestMapping("/blog-comments")
public class BlogCommentsController {
    @Resource
    private IBlogCommentsService blogCommentsService;

    //查询某个博客下的评论
    @GetMapping("/{id}")
    public Result getBlogComments(@PathVariable("id") Long id){
        return blogCommentsService.getBlogComments(id);
    }


    /*
    * 给评论点赞
    * */
    @PostMapping("/like/{id}")
    public Result likeBlogComment(@PathVariable("id") Long id){
        return blogCommentsService.likeBlogComment(id);
    }

    @PostMapping
    public Result saveBlogComment(@RequestBody BlogComments blogComments){
        return blogCommentsService.saveBlogComment(blogComments);
    }
}
